from django_celery_beat.models import PeriodicTask
from rest_framework import serializers
from apps.CeleryTimedTask.serializers import CrontabScheduleSerializers


class TimedTaskSerializers(serializers.ModelSerializer):
    crontab_id = serializers.CharField(write_only=True)
    crontab = CrontabScheduleSerializers(read_only=True)
    start_time = serializers.DateTimeField(format="%Y-%m-%d %H:%M:%S")
    expires = serializers.DateTimeField(format="%Y-%m-%d %H:%M:%S")

    class Meta:
        model = PeriodicTask
        fields = '__all__'
